#include "src/scene/energyColor.h"

#include <iostream>
#include <cstdlib>


EnergyColor::EnergyColor() : Color(){
	energy = 1.0;
}

EnergyColor::EnergyColor(const EnergyColor &_color) : Color(){
    *this = _color;
}

EnergyColor::EnergyColor(const Color &_color, double _energy) : Color(_color), energy(_energy){
}

EnergyColor::EnergyColor(const unsigned int &_color) : Color (_color){
    energy = 1.0;
}

EnergyColor::EnergyColor(const double &_r, const double &_g, const double &_b, const double &_a, const double &_e) : Color(_r, _g, _b, _a), energy(_e) {}

EnergyColor::~EnergyColor(){}

double EnergyColor::operator[](const unsigned int &_i) const
{
    switch(_i){
        case 0:
            return red;
            break;
        case 1:
            return green;
            break;
        case 2:
            return blue;
            break;
        case 3:
            return alpha;
            break;
        case 4:
            return energy;
            break;
    }
    std::cout <<"Erro no operador [] de EnergyColor!"<<std::endl;
    exit(1);
}

EnergyColor &EnergyColor::operator=(const EnergyColor &_c) {
	if(this != &_c) {
		red = _c.red;
		green = _c.green;
		blue = _c.blue;
		alpha = _c.alpha;
		energy = _c.energy;
	}
	return *this;
}

bool EnergyColor::operator==(const EnergyColor &_c) const {
    return  (red == _c.red) && (green == _c.green) && (blue == _c.blue) && (alpha == _c.alpha) && (energy == _c.energy);
}

bool EnergyColor::operator!=(const EnergyColor &_c) const {
    return  (red != _c.red) || (green != _c.green) || (blue != _c.blue) || (alpha != _c.alpha) || (energy != _c.energy);
}

EnergyColor EnergyColor::operator+(const EnergyColor &_color) const {
    double r = _color.red + red;
    double g = _color.green + green;
    double b = _color.blue + blue;
    double a = _color.alpha + alpha;
    double e = _color.energy + energy;

	return EnergyColor(r, g, b, a, e);
}

EnergyColor EnergyColor::operator-(const EnergyColor &_color) const {
    double r = red - _color.red;
    double g = green - _color.green;
    double b = blue - _color.blue;
    double a = alpha - _color.alpha;
    double e = energy - _color.energy;

	return EnergyColor(r, g, b, a, e);
}

EnergyColor EnergyColor::operator*(const EnergyColor &_color) const {
    double r = red * _color.red;
    double g = green * _color.green;
    double b = blue * _color.blue;
    double a = alpha * _color.alpha;
    double e = energy * _color.energy;

	return EnergyColor(r, g, b, a, e);
}

EnergyColor EnergyColor::operator*(const Color &_color) const {
    double r = red * _color.red;
    double g = green * _color.green;
    double b = blue * _color.blue;
    double a = alpha * _color.alpha;

	return EnergyColor(r, g, b, a, energy);
}

EnergyColor EnergyColor::operator*(const double &_d) const {
    double e = energy * _d;

	return EnergyColor(red, green, blue, alpha, e);
}

EnergyColor EnergyColor::operator/(const double &_d) const {
    double e = energy / _d;

	return EnergyColor(red, green, blue, alpha, e);
}

void EnergyColor::print() const {
    std::cout << "Cor [ " <<red << ", " << green << ", " << blue << ", " << alpha <<"] - Energia [" << energy << "]"<<std::endl;
}

